package items;
import javax.swing.*; 
import java.awt.*;
public class Table extends JPanel {
    private JLayeredPane layeredPane;
    private JLabel CardOne;
    private JLabel CardTwo;
    private JLabel CardThree;
    private JLabel CardFour;
    private JLabel CardFive;
    private JLabel Table;
    public Table()    {
        setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
        final ImageIcon iconTable = createImageIcon("Table_Carpet.jpg");
        layeredPane = new JLayeredPane();
        layeredPane.setPreferredSize(new Dimension(800, 510));
        Table = new JLabel(iconTable);
        Table.setBounds(0,0,iconTable.getIconWidth(),iconTable.getIconHeight());
        dealCard("Jc",1);
        dealCard("Js",2);
        dealCard("Jh",3);
        dealCard("Ac",4);
        dealCard("Jc",5);
        layeredPane.add(Table, new Integer (1), 0);
        add(layeredPane);
    }
    public void dealCard(String Card, int spot){
    	String path = Card.concat(".png");
    	ImageIcon icon = createImageIcon(path);
    	if (spot == 1){
    	CardOne = new JLabel(icon);
    	layeredPane.add(CardOne, new Integer(2), 0);
    	CardOne.setBounds(225, 160,icon.getIconWidth(),icon.getIconHeight());}
    	else if (spot == 2){
    	CardTwo = new JLabel(icon);
        layeredPane.add(CardTwo, new Integer(2), 0);
        CardTwo.setBounds(300, 160,icon.getIconWidth(),icon.getIconHeight());	
    	}
    	else if (spot == 3){
    		CardThree = new JLabel(icon);
            layeredPane.add(CardThree, new Integer(2), 0);
            CardThree.setBounds(375, 160,icon.getIconWidth(),icon.getIconHeight());	
        	}
    	else if (spot == 4){
    		CardFour = new JLabel(icon);
            layeredPane.add(CardFour, new Integer(2), 0);
            CardFour.setBounds(450, 160,icon.getIconWidth(),icon.getIconHeight());	
        	}
    	else if (spot == 5){
    		CardFive = new JLabel(icon);
            layeredPane.add(CardFive, new Integer(2), 0);
            CardFive.setBounds(525, 160,icon.getIconWidth(),icon.getIconHeight());	
        	}
    }
    protected static ImageIcon createImageIcon(String path) {
        java.net.URL imgURL = Table.class.getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }

    public static void createAndShowGUI() {
        JFrame frame = new JFrame("Michael's Poker Program - Table");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JComponent newContentPane = new Table();
        newContentPane.setOpaque(true);
        frame.setContentPane(newContentPane);
        frame.pack();
        frame.setBackground(Color.black);
        frame.setVisible(true);
    }
 
   
}
	